]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionDownloader: Properly error out when downloading/parsing infos
authorJasper St. Pierre <jstpierre@mecheye.net>
Sat, 16 Jun 2012 02:38:55 +0000 (22:38 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Mon, 2 Jul 2012 22:29:56 +0000 (18:29 -0400)
When the extension downloader was originally designed, the information
downloading part was inserted at the last minute, along with the modal
dialog as a security feature to make sure an extension didn't silently
get installed on the user's machines either due to a security issue in
the browser-plugin, or an XSS issue on the extensions website. Correct
the mistake I made when writing the code; instead of dropping an error
on the floor, log it correctly. This "bug" has already bitten a number
of users who forgot to configure proxy settings in the control center.

https://bugzilla.gnome.org/show_bug.cgi?id=679099

js/ui/extensionDownloader.js

index b1c0810a30710e8451b4acf1e3dce9df001fe668..e9f49524c77c681e05f2a4882cc3272f08472a14 100644 (file)
@@ -28,12 +28,23 @@ function installExtensionFromUUID(uuid) {
 
     let message = Soup.form_request_new_from_hash('GET', REPOSITORY_URL_INFO, params);
 
-    _httpSession.queue_message(message,
-                               function(session, message) {
-                                   let info = JSON.parse(message.response_body.data);
-                                   let dialog = new InstallExtensionDialog(uuid, info);
-                                   dialog.open(global.get_current_time());
-                               });
+    _httpSession.queue_message(message, function(session, message) {
+        if (message.status_code != Soup.KnownStatusCode.OK) {
+            ExtensionSystem.logExtensionError(uuid, 'downloading info: ' + message.status_code);
+            return;
+        }
+
+        let info;
+        try {
+            info = JSON.parse(message.response_body.data);
+        } catch (e) {
+            ExtensionSystem.logExtensionError(uuid, 'parsing info: ' + e);
+            return;
+        }
+
+        let dialog = new InstallExtensionDialog(uuid, info);
+        dialog.open(global.get_current_time());
+    });
 }
 
 function uninstallExtensionFromUUID(uuid) {
@@ -85,6 +96,12 @@ function gotExtensionZipFile(session, message, uuid) {
     GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function(pid, status) {
         GLib.spawn_close_pid(pid);
 
+        if (status != 0) {
+            ExtensionSystem.logExtensionError(uuid, 'extract: could not extract');
+            invocation.return_dbus_error('org.gnome.Shell.ExtractExtensionError', '');
+            return;
+        }
+
         // Add extension to 'enabled-extensions' for the user, always...
         let enabledExtensions = global.settings.get_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY);
         if (enabledExtensions.indexOf(uuid) == -1) {